<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>POST方式实现AJAX</title>
</head>
<body>
<form autocomplete="off">
    姓名：<input type="text" id="username">
    <span id="uSpan"></span>
    <br>
    密码：<input type="password" id="password">
    <br>
    <input type="submit" value="注册">
</form>
</body>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
    //用户名绑定失去焦点事件
    $("#username").blur(function () {
        //获取username内容
        let username = $("#username").val();
        //post实现Ajax
        $.post(
            //获取路径
            "userServlet",
            //请求参数
            "username="+username,
            //回调函数
            function (date) {
              //响应的数据显示到span标签
              $("#uSpan").html(date)
            },
            "text"
        );

    });
</script>
</html>